package com.example.demo.Controller;

import com.example.demo.bean.salesorder;
import com.example.demo.service.salesorderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import com.example.demo.service.salesorderService;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;
@RestController
@Api(tags="订单管理")

@RequestMapping("/salesorder")
public class salesorderController {
    @Autowired
    private  salesorderService salesorderService;

    /**
     *
     * @param salesorder
     * @return
     */
    @PostMapping("/Insertsalesorder")
    @ApiOperation(value = "增加订单信息", notes = "插入订单信息")
    @ResponseBody
    public int Insertsalesorder( salesorder salesorder){
         salesorderService.Insertsalesorder(salesorder);return 1;
    }

    /**
     *
     * @param ordersid
     * @return
     */
    @PostMapping("/Deletesalesorder")
    @ApiOperation(value = "删除订单信息", notes = "根据订单Id")
    @ResponseBody
    public int Deletesalesorder(@RequestParam("ordersid") Integer ordersid){

        salesorderService.Deletesalesorder(ordersid);return 1;
    }

    /**
     *
     * @param salesorder
     * @return
     */

    @PostMapping("/Updatesalesorder")
    @ApiOperation(value = "更新订单信息", notes = "根据订单Id修改信息")
    @ResponseBody
    public int Updatesalesorder( salesorder salesorder) {
        salesorderService.Updatesalesorder(salesorder); return 1;
    }

    /**
     *
     * @return
     */
    @PostMapping("/ShowAllsalesorder")
    @ApiOperation(value = "获取订单信息列表", notes = "获取所有订单信息")
    @ResponseBody
    public List<salesorder> ShowAllsalesorder() {
        return salesorderService.ShowAllsalesorder();
    }

    @PostMapping("/Totalsalesorder")
    @ApiIgnore
    @ResponseBody
    public int Totalsalesorder(){
        return salesorderService.Totalsalesorder();
    };

}
